package team.knowers.qzh.qzhserver.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import team.knowers.qzh.qzhserver.common.convention.result.Result;
import team.knowers.qzh.qzhserver.common.convention.result.Results;
import team.knowers.qzh.qzhserver.dto.req.AddEvaluationReqDTO;
import team.knowers.qzh.qzhserver.dto.req.EvaluationPageReqDTO;
import team.knowers.qzh.qzhserver.dto.resp.EvaluationPageRespDTO;
import team.knowers.qzh.qzhserver.service.CourseEvaluationService;

/**
 * @author xtg
 */
@RestController
@RequiredArgsConstructor
public class CourseEvaluationController {
    private final CourseEvaluationService courseEvaluationService;

    /**
     * 添加一条评价
     *
     * @param request 评价
     * @return
     */
    @PostMapping("/api/qzh-server/admin/v1/course/evaluation")
    public Result<Integer> addEvaluation(@RequestBody AddEvaluationReqDTO request) {
        return Results.success(courseEvaluationService.addEvaluation(request));
    }

    /**
     * 分页查询评价
     */
    @GetMapping("/api/qzh-server/admin/v1/course/evaluation")
    public Result<IPage<EvaluationPageRespDTO>> pageEvaluation(EvaluationPageReqDTO request) {
        return Results.success(courseEvaluationService.pageEvaluation(request));
    }


}
